package com.gk.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * 诗词entity
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Document(type = "poem", indexName = "poems")
public class Poem {

    @Id
    private String id;

    @Field(analyzer = "ik_max_word", type = FieldType.Text)
    private String name; //诗词名

    @Field(type = FieldType.Keyword)
    private String author; //作者

    @Field(type = FieldType.Keyword)
    private String type; //诗词类型

    @Field(analyzer = "ik_max_word", type = FieldType.Text)
    private String content; //内容

    @Field(type = FieldType.Keyword)
    private String href; //诗词网站

    @Field(analyzer = "ik_max_word", type = FieldType.Text)
    private String authordes; //作者简介

    @Field(type = FieldType.Keyword)
    private String origin;  //来源

    //Nested   告诉ES当前是一个对象
    @Field(type = FieldType.Nested)
    private Category category = new Category(); //诗体
}
